<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.infodms.dms.common.Constant" %>
<%
	String contextPath = request.getContextPath();
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@taglib uri="/jstl/cout" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<title>集团客户支持</title>
</head>
<body>
<div class="navigation"><img src="<%=contextPath%>/img/nav.gif" />&nbsp;集团客户支持>集团客户支持申请>集团客户支持申请意向录入</div>
<form method="post" name = "fm" >
	<div><img class="nav" src="<%=contextPath%>/img/subNav.gif" />&nbsp;提报单位信息</div>
	<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		<tr>
			<th colspan="4" align="left">&nbsp;单位信息</th>
		</tr>
		<tr>
			<td class="table_query_2Col_label_4Letter">提报单位：</td>
			<td><c:out value="${fleetMap.COMPANY_SHORTNAME}"/></td>
			<td class="table_query_2Col_label_4Letter">批售经理：</td>
			<td><c:out value="${fleetMap.NAME}"/></td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_4Letter">提报日期：</td>
			<td><c:out value="${fleetMap.SUBMIT_DATE}"/></td>
		</tr>
	</table>
	<div><img class="nav" src="<%=contextPath%>/img/subNav.gif" />&nbsp;集团客户信息</div>
	<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		<tr>
			<th colspan="4" align="left">&nbsp;客户信息</th>
		</tr>
		<tr>
			<td class="table_query_2Col_label_4Letter">客户名称：</td>
			<td><c:out value="${fleetMap.FLEET_NAME}"/></td>
			<td class="table_query_2Col_label_4Letter">客户类型：</td>
			<td>
				<script type='text/javascript'>
					writeItemValue('<c:out value="${fleetMap.FLEET_TYPE}"/>');
				</script>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_4Letter">主营业务：</td>
			<td>
				<script type='text/javascript'>
					writeItemValue('<c:out value="${fleetMap.MAIN_BUSINESS}"/>');
				</script>
			</td>
			<td class="table_query_2Col_label_4Letter">资金规模：</td>
			<td>
				<script type='text/javascript'>
					writeItemValue('<c:out value="${fleetMap.FUND_SIZE}"/>');
				</script>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_4Letter">人员规模：</td>
			<td>
				<script type='text/javascript'>
					writeItemValue('<c:out value="${fleetMap.STAFF_SIZE}"/>');
				</script>
			</td>
			<td class="table_query_2Col_label_4Letter">购车用途：</td>
			<td>
				<script type='text/javascript'>
					writeItemValue('<c:out value="${fleetMap.PURPOSE}"/>');
				</script>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_4Letter">区域：</td>
			<td>
				<script type='text/javascript'>
					writeRegionName('<c:out value="${fleetMap.REGION}"/>');
				</script>
			</td>
			<td class="table_query_2Col_label_4Letter">邮编：</td>
			<td><c:out value="${fleetMap.ZIP_CODE}"/></td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_4Letter">详细地址：</td>
			<td><c:out value="${fleetMap.ADDRESS}"/></td>
		</tr>
		<tr>
			<th colspan="4" align="left">&nbsp;联系人信息</th>
		</tr>
		<tr>
			<td class="table_query_2Col_label_5Letter">主要联系人：</td>
			<td><c:out value="${fleetMap.MAIN_LINKMAN}"/></td>
			<td class="table_query_2Col_label_4Letter">职务：</td>
			<td><c:out value="${fleetMap.MAIN_JOB}"/></td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_5Letter">电话：</td>
			<td><c:out value="${fleetMap.MAIN_PHONE}"/></td>
			<td class="table_query_2Col_label_4Letter">电子邮件：</td>
			<td><c:out value="${fleetMap.MAIN_EMAIL}"/></td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_5Letter">其他联系人：</td>
			<td><c:out value="${fleetMap.OTHER_LINKMAN}"/></td>
			<td class="table_query_2Col_label_4Letter">职务：</td>
			<td><c:out value="${fleetMap.OTHER_JOB}"/></td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_5Letter">电话：</td>
			<td><c:out value="${fleetMap.OTHER_PHONE}"/></td>
			<td class="table_query_2Col_label_4Letter">电子邮件：</td>
			<td><c:out value="${fleetMap.OTHER_EMAIL}"/></td>
		</tr>
		<tr>
			<th colspan="4" align="left">&nbsp;需求说明</th>
		</tr>
		<tr>
			<td class="table_query_2Col_label_5Letter">需求车系：</td>
			<td><c:out value="${fleetMap.GROUP_NAME}"/></td>
			<td class="table_query_2Col_label_4Letter">需求数量：</td>
			<td><c:out value="${fleetMap.SERIES_COUNT}"/></td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_5Letter">备注：</td>
			<td colspan="3" align="left"><c:out value="${fleetMap.REQ_REMARK}"/></td>
		</tr>
	</table>
	<c:if test="${checkList!=null}">
		<div><img class="nav" src="<%=contextPath%>/img/subNav.gif" />&nbsp;审核信息</div>
		<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
			<tr>
			<th colspan="5" align="left">&nbsp;审核记录</th>
			</tr>
			<tr align="center">
				<td>审核部门</td>
				<td>审核时间</td>
				<td>审核人</td>
				<td>审核意见</td>
				<td>审核结果</td>
			</tr>
			<c:forEach items="${checkList}" var="checkList">
				<tr align="center">
					<td>${checkList.ORG_NAME}</td>
					<td>${checkList.AUDIT_DATE}</td>
					<td>${checkList.USER_NAME}</td>
					<td>${checkList.AUDIT_REMARK}</td>
					<td>${checkList.CHECK_STATUS}</td>
				</tr>
			</c:forEach>
		</table>
	</c:if>
	<div><img class="nav" src="<%=contextPath%>/img/subNav.gif" />&nbsp;购车意向</div>
	<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		<tr>
			<th colspan="4" align="left">&nbsp;意向信息</th>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">预计采购日期：</td>
			<td align="left">
           		<input name="purchaseDate" id="t1" value="${intentMap.PURCHASE_DATE}" type="text" class="short_txt" datatype="0,is_date,10" group="t1,t2" hasbtn="true" callFunction="showcalendar(event, 't1', false);">
           		&nbsp;至&nbsp;
           		<input name="purendDate" id="t2" value="${intentMap.PUR_END_DATE}" type="text" class="short_txt" datatype="0,is_date,10" group="t1,t2" hasbtn="true" callFunction="showcalendar(event, 't2', false);">
			</td>
			<td class="table_query_2Col_label_6Letter">信息来源：</td>
			<td align="left"><input type="text" name="infoGivingMan" value="${intentMap.INFO_GIVING_MAN}"/></td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">竞争情况说明：</td>
			<td  colspan="3" align="left">
				<textarea name="competeRemark" id="competeRemark" rows="2" cols="60" datatype="0,null,300">${intentMap.COMPETE_REMARK}</textarea>
			</td>
		</tr>
		<tr>
			<td class="table_query_2Col_label_6Letter">其他说明：</td>
			<td  colspan="3" align="left">
				<textarea name="infoRemark" id="infoRemark" rows="2" cols="60">${intentMap.INFO_REMARK}</textarea>
			</td>
		</tr>
	</table>
	<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		<tr>
			<th colspan="7" align="left">&nbsp;意向车型
				<input class="cssbutton" name="add22" type="button" onclick="addNewGroup()" value ='新增' />
				<input type="text" name="materialCode" size="15" id="materialCode" style="display:none"/>
			</th>
		</tr>
		<tr align="center">
			<td width="20%" align="center">意向车系</td>
			<td width="5%" align="center">数量</td>
			<td width="10%" align="center">支持点位</td>
			<td width="30%" align="center">备注</td>
			<td width="5%" align="center">操作</td>
		</tr>
		<tbody id="tbody1">
			<c:if test="${intentId!=null}">
				<c:forEach items="${intentList}" var="list">
					<tr align="center" class="table_list_row2">
						<td>${list.GROUP_NAME}</td>
						<td><input id="amount" name="amount" type="text" class="SearchInput"  value="${list.AMOUNT}" size="3" maxlength="6"/></td>
						<td><input id="discount" name="discount" type="text" class="SearchInput" value="${list.DISCOUNT}" size="3" maxlength="3"/>%</td>
						<td><input id="remark" name="remark" type="text" class="SearchInput" value="${list.REMARK}" size="40" maxlength="200"/></td>
						<td><a href="#" onclick="delMaterial();">[删除]</a><input type='hidden' id="groupId${list.INTENT_MODEL}" name="groupId" value="${list.INTENT_MODEL}"></td>
					</tr>
				</c:forEach>
			</c:if>
		</tbody>
		</table>
		<table width=100% border="0" align="center" cellpadding="1" cellspacing="1" class="table_query">
		<tr align="center">
			<td colspan="5">
				<input type="hidden" name="groupIds" id="Ids"/>
				<input type="hidden" name="remarks" id="remarks"/>
				<input type="hidden" name="originalPrices" id="originalPrices"/>
				<input type="hidden" name="discounts" id="discounts"/>
				<input type="hidden" name="discountPrices" id="discountPrices"/>
				<input type="hidden" name="amounts" id="amounts"/>
				<input type="hidden" name="fleetId" id="fleetId" value="${fleetMap.FLEET_ID}"/>
				<input type="hidden" name="intentId" id="intentId" value="${intentId}"/>
				<input class="cssbutton" name="button1" type="button" onclick="toSave();" value ="保存" />
				<input class="cssbutton" name="button3" type="button" onclick="toSubmit();" value ="申请" />
				<input class="cssbutton" name="button2" type="button" onclick="toBack();" value ="返回" />
			</td>
		</tr>
	</table>
</form>
<script type="text/javascript"><!--
	function doInit(){
		loadcalendar();  //初始化时间控件
	}
	//物料弹出选择
	function addNewGroup(){
		var ids = "";
		var myForm = document.getElementById("fm");
		for (var i=0; i<myForm.length; i++){  
			var obj = myForm.elements[i];
			if(obj.id.length>=7 && obj.id.substring(0,7)=="groupId"){
				if(ids&&ids.length>0){
					ids = ids +","+ obj.value;
				}else{
					ids = obj.value;
				}
			}   
		}
		OpenHtmlWindow(g_webAppName+"/jsp/sales/fleetmanage/fleetSupport/addNewGroup.jsp?GROUPLEVEL=2&GROUPIDS="+ids,770,410);
	}
	//删除产品链接
	function delMaterial(){	
	  	document.getElementById("tbody1").deleteRow(window.event.srcElement.parentElement.parentElement.rowIndex-2);  
	}
	//新增产品列表
	function addRow(value1,value2,value3){		
		var timeValue = new Date().getTime();
		var newRow = document.getElementById("tbody1").insertRow();
		newRow.className  = "table_list_row2";
		var newCell = newRow.insertCell(0);
		newCell.align = "center";
		newCell.innerHTML = value2;
		newCell = newRow.insertCell(1);
		newCell.align = "center";
		newCell.innerHTML = "<input id='amount"+timeValue+"' name='amount' type='text' class='SearchInput' value='' size='3' maxlength='6'/>";
		newCell = newRow.insertCell(2);
		newCell.align = "center";
		newCell.innerHTML = "<input id='discount"+timeValue+"' name='discount' type='text' class='SearchInput' value='' size='3' maxlength='3'/>%";
		newCell = newRow.insertCell(3);
		newCell.align = "center";
		newCell.innerHTML = "<input id='remark"+timeValue+"' name='remark' type='text' class='SearchInput' size='40' maxlength='200'/>";
		newCell = newRow.insertCell(4);
		newCell.align = "center";
		newCell.innerHTML = "<a href='#' onclick='delMaterial();'>[删除]</a><input type='hidden' id='groupId"+timeValue+"' name='groupId' value='"+value1+"'>";
		
	}
	//保存校验
	function toSave(){
		var purchaseDate = document.getElementById("purchaseDate").value;
		var competeRemark = document.getElementById("competeRemark").value;
		var purendDate = document.getElementById("purendDate").value;
		if(!purchaseDate){
			MyAlert("请填写预计采购时间！");
			return false;
		}
		if(!purendDate){
			MyAlert("请填写预计采购时间!");
			return false;
		}
		if(!competeRemark){
			MyAlert("请填写竞争情况说明！");
			return false;
		}
		var groupIds ='';
		var remarks ='';
		var amounts = '';
		var discounts ='';
		var groupId = document.getElementsByName("groupId");
		var remark = document.getElementsByName("remark");
		var amount = document.getElementsByName("amount");
		var discount = document.getElementsByName("discount");
		for(var i=0 ;i< groupId.length; i++){
			/*if(remark[i].value.trim()==""){
				MyAlert("车型备注不能为空！");
				return false;
			}*/
			if(amount[i].value.trim()==""){
				MyAlert("数量不能为空！");
				return false;
			}
			if(discount[i].value.trim()==""){
				MyAlert("支持点位不能为空！");
				return false;
			}

			groupIds = groupId[i].value + ',' + groupIds;

			if(remark[i].value.trim()==""){
				remarks = 'null,' + remarks;
			}
			else{
				remarks = remark[i].value + ',' + remarks;
			}

			amounts = amount[i].value + ',' + amounts;

			discounts = discount[i].value + ',' + discounts;
		}
		document.getElementById("Ids").value=groupIds;
		document.getElementById("remarks").value=remarks;
		document.getElementById("amounts").value=amounts;
		document.getElementById("discounts").value=discounts;
		MyConfirm("确认保存？",toAdd);
	}
	//保存提交
	function toAdd(){
		makeNomalFormCall('<%=request.getContextPath()%>/sales/fleetmanage/fleetSupport/FleetSupportApply/fleetSupportApplySave.json',showResult,'fm');
	}
	//申请校验
	function toSubmit(){
		var purchaseDate = document.getElementById("purchaseDate").value;
		var competeRemark = document.getElementById("competeRemark").value;
		var purendDate = document.getElementById("purendDate").value;
		var newRow = document.getElementById("tbody1").childNodes.length;
		if(newRow<1){
			MyAlert("请填写意向车型！");
			return false;
		}
		if(!purchaseDate){
			MyAlert("请填写预计采购时间！");
			return false;
		}
		if(!purendDate){
			MyAlert("请填写预计采购时间！");
			return false;
		}
		if(!competeRemark){
			MyAlert("请填写竞争情况说明！");
			return false;
		}
		var groupIds ='';
		var remarks ='';
		var amounts = '';
		var discounts ='';
		var groupId = document.getElementsByName("groupId");
		var remark = document.getElementsByName("remark");
		var amount = document.getElementsByName("amount");
		var discount = document.getElementsByName("discount");
		for(var i=0 ;i< groupId.length; i++){
			/*if(remark[i].value.trim()==""){
				MyAlert("车型备注不能为空！");
				return false;
			}*/
			if(amount[i].value.trim()==""){
				MyAlert("数量不能为空！");
				return false;
			}
			if(discount[i].value.trim()==""){
				MyAlert("支持点位不能为空！");
				return false;
			}
			groupIds = groupId[i].value + ',' + groupIds;
			if(remark[i].value.trim()==""){
				remarks = 'null,' + remarks;
			}
			else{
				remarks = remark[i].value + ',' + remarks;
			}
			amounts = amount[i].value + ',' + amounts;
			discounts = discount[i].value + ',' + discounts;
		}
		document.getElementById("Ids").value=groupIds;
		document.getElementById("remarks").value=remarks;
		document.getElementById("amounts").value=amounts;
		document.getElementById("discounts").value=discounts;
		MyConfirm("确认申请？",toConfirm);
	}
	//申请提交
	function toConfirm(){
		makeNomalFormCall('<%=request.getContextPath()%>/sales/fleetmanage/fleetSupport/FleetSupportApply/fleetSupportApplyConfirm.json',showResult,'fm');
	}
	//返回
	function toBack(){
		fm.action='<%=request.getContextPath()%>/sales/fleetmanage/fleetSupport/FleetSupportApply/fleetSupportApplyInit.do';
		fm.submit();
	}
	//回调方法
	function showResult(json){
		if(json.returnValue == '1'){
			window.parent.MyAlert("操作成功！");
			fm.action='<%=request.getContextPath()%>/sales/fleetmanage/fleetSupport/FleetSupportApply/fleetSupportApplyInit.do';
			fm.submit();
		}else{
			MyAlert("操作失败！请联系系统管理员！");
		}
	}
--></script>
</body>
</html>